<?php
/**
 * File: Tool.php:YCMS
 * User: xiaoyan f@yanyunfeng.com
 * Date: 15-5-13
 * Time: 上午9:26
 * @Description
 */
class Tool extends Controller
{

    public function init()
    {
        $this->addRoute('/tool/excel/test', function () {
            $s = 'a:1:{s:6:"choice";s:40:"1=默认类型
2=必须完成
3=不管";}';
            $ss = unserialize($s);
            $c = explode("\n",$ss['choice']);
            $ss['choice'] = array();
            foreach($c as $i => $so){
                preg_match('/^([A-Za-z0-9_]+?)=(.*)$/',$so,$si);
                $ss['choice'][] = array('text'=>$si[2],'value'=>$si[1]);
            }
            echo serialize($ss);
        });
        $this->addRoute('/tool/cache',function(){
            $cache = new Memcache();
            $cache->connect('127.0.0.1',11211);
            if(($item = $cache -> get('ycms_chart_7days'))){
                print_r($item);
            }else{
                $cache->set('ycms_chart_7days',serialize($_SESSION));
            }

        });
    }

    private function un($str)
    {
        print_r(unserialize($str));

    }
}